主题
获取软件更新状态 - GetSoftUpdateStatus
函数简介
获取客户端软件更新状态,并返回最新版本业务信息。
本接口只负责查询。若要下载并安装/覆盖,请调用 SoftUpdateStart(见 软件自更新模块总览)。不要再寻找名为 SoftUpdateCheck 的接口——已移除,避免与本接口重复。
返回数据格式:
json
{
"Code": 1,
"Message": "",
"CurrentVersion": "1.0.0",
"LatestVersion": "1.1.0",
"HasUpdate": true,
"SoftVersion": {
"SoftCode": "demo-soft",
"VersionNumber": "1.1.0",
"VersionName": "2026春季版",
"VersionType": 1,
"FileName": "demo-installer.exe",
"FileSize": 12345678,
"FileMd5": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"FileUrl": "https://example.com/demo-installer.exe",
"IsForceUpdate": false,
"UpdateContent": "修复已知问题并优化稳定性",
"ReleaseDate": "2026-04-24 09:00:00",
"IsLatest": true
}
}| 字段名 | 类型 | 说明 |
|---|---|---|
| Code | 整数 | 结果状态码,通常 1 表示成功,0 或其他值表示失败。 |
| Message | 字符串 | 提示信息或错误信息;失败时多为 错误码:中文描述(如 "2003:参数无效")。成功时可能为 success。完整对照见 客户端错误码说明。 |
| CurrentVersion | 字符串 | 当前版本号。 |
| LatestVersion | 字符串 | 最新版本号。 |
| HasUpdate | 布尔 | 是否存在可更新版本。 |
| SoftVersion | 对象 | 版本对象信息。 |
常见错误码(Message 字段)
| Message | 含义 |
|---|---|
2003:参数无效 | 参数无效 |
2004:用户不存在 | 用户不存在 |
2005:软件不可用或未开通 | 软件不可用或未开通 |
SoftVersion 字段说明:
| 字段名 | 类型 | 说明 |
|---|---|---|
| SoftCode | 字符串 | 软件编码。 |
| VersionNumber | 字符串 | 版本号。 |
| VersionName | 字符串 | 版本名称。 |
| VersionType | 整数 | 版本类型编码。 |
| FileName | 字符串 | 安装包文件名。 |
| FileSize | 整数 | 安装包大小(字节)。 |
| FileMd5 | 字符串 | 安装包 MD5 校验值。 |
| FileUrl | 字符串 | 安装包下载地址。 |
| IsForceUpdate | 布尔 | 是否强制更新。 |
| UpdateContent | 字符串 | 更新说明内容。 |
| ReleaseDate | 字符串 | 版本发布时间。 |
| IsLatest | 布尔 | 是否为最新版本。 |
接口名称
GetSoftUpdateStatusDLL调用
long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| userCode | 字符串 | 用户码。 |
| softCode | 字符串 | 软件码。 |
| softVersion | 字符串 | 软件版本。 |
| dealerCode | 字符串 | 经销商码。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功csharp
using OLAPlug;
var ola = new OLAPlugServer();
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
json_result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
# Python SDK 返回 JSON 字符串,需自行解析java
import com.olaplug.OLAPlugServer;
import com.olaplug.model.OlaAuthSoftUpdateStatusReturn;
OLAPlugServer ola = new OLAPlugServer();
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
result := ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")
// result.Code == 1 表示成功rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let result = ola.get_soft_update_status("userCode", "softCode", "1.0.0", "dealerCode");
// result.code == 1 表示成功cpp
var ola = com("OlaPlug.OlaSoft")
var result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
Set result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")text
.局部变量 ola, OLAPlug
.局部变量 result, OlaAuthSoftUpdateStatusReturn
ola.创建 ()
result = ola.GetSoftUpdateStatus(“userCode”, “softCode”, “1.0.0”, “dealerCode”)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var json = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// Aardio SDK 返回 JSON 字符串,需自行解析text
变量 ola <类型 = OLAPlugServer>
变量 result <类型 = OlaAuthSoftUpdateStatusReturn>
ola = 新建 OLAPlugServer
result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
OlaAuthSoftUpdateStatusReturn result = ola.GetSoftUpdateStatus("userCode", "softCode", "1.0.0", "dealerCode");
// result.Code == 1 表示成功原生 DLL 调用
cpp
long ptr = GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode");
if (ptr != 0) {
char buffer[512] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetSoftUpdateStatus(string userCode, string softCode, string softVersion, string dealerCode);
long ptr = GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode");
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string result = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetSoftUpdateStatus(instance, "userCode", "softCode", "1.0.0", "dealerCode")
if ptr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(ptr, buf, 512)
ola.FreeStringPtr(ptr)
result = buf.value.decode("utf-8")返回值
| 调用方式 | 返回值 | 说明 |
|---|---|---|
| SDK | OlaAuthSoftUpdateStatusReturn | 结构化返回对象;Code == 1 表示成功 |
| 原生 DLL | 非 0 | 成功,返回 JSON 字符串格式的结果。 |
| 原生 DLL | 0 | 失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 释放内存 | 返回的字符串指针需要调用 FreeStringPtr 接口释放内存。 |
HasUpdate 可直接用于判断是否提示更新 | HasUpdate 可直接用于判断是否提示更新。 |
| 历史更新说明 | 需要展示多版本更新日志时,请使用 GetSoftUpdateLogs。 |
